package com.pdg.mcplugin.tsa;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;

import com.pdg.mcplugin.common.ArgumentList;
import com.pdg.mcplugin.common.baseclasses.PluginBase;

public class TSA extends PluginBase{

	private static final String COMMAND_TSA = "TSA";
	private DataProvider dataProvider=null;
	public DataProvider getDataProvider(){
		if(dataProvider==null){
			dataProvider = new DataProvider(this);
		}
		return dataProvider;
	}
	private CommandProcessor commandProcessor=null;
	private CommandProcessor getCommandProcessor() {
		if(commandProcessor==null){
			commandProcessor = new CommandProcessor(this);
		}
		return commandProcessor;
	}
	private PermissionChecker permissionChecker = null;
	public PermissionChecker getPermissionChecker(){
		if(permissionChecker==null){
			permissionChecker = new PermissionChecker(this);
		}
		return permissionChecker;
	}
	private ContrabandManager contrabandManager = null;
	public ContrabandManager getContrabandManager(){
		if(contrabandManager==null){
			contrabandManager = new ContrabandManager(this);
		}
		return contrabandManager;
	}

	@Override
	protected void disablePlugin() {
	}

	@Override
	protected boolean enablePlugin() {
		saveDefaultConfig();
		getDataProvider().upgradeDatabase();
		return true;
	}
	//handle commands
	public boolean onCommand(CommandSender theCommandSender, Command theCommand, String theLabel, String[] theArgs){
		ArgumentList theArgumentList = new ArgumentList(theArgs);
		if(theCommand.getName().equalsIgnoreCase(COMMAND_TSA)){
			return getCommandProcessor().processCommand(theCommandSender,theArgumentList);
		}
		return false;
	}

}
